package com.zy.web.controller.bs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.entity.bs.CustomerClubApply;
import com.zy.pojo.query.bs.CustomerClubApplyQuery;
import com.zy.pojo.vos.common.PageVo;
import com.zy.pojo.vos.common.ResultVo;
import com.zy.service.bs.CustomerClubApplyService;
import com.zy.web.controller.base.BaseController;
import com.zy.web.utils.ResultUtil;

import java.io.Serializable;

@RequestMapping({"bs/customerClubApply","m/bs/customerClubApply"})
@Controller
public class CustomerClubApplyController extends BaseController {

	@Autowired
	private CustomerClubApplyService customerClubApplyService;

	/**
	 * 分页
 	 * 
 	 * @param customerClubApplyQuery
	 * @param start
	 * @param limit
	 * @return
	 */
	@RequestMapping("pageCustomerClubApply")
	@ResponseBody
	public PageVo pageCustomerClubApply(CustomerClubApplyQuery customerClubApplyQuery, Integer start, Integer limit) {
		return this.customerClubApplyService.pageCustomerClubApply(customerClubApplyQuery, start, limit);
	}

	/**
	 * 新增
	 * 
	 * @param customerClubApply
	 * @return
	 */
	@RequestMapping(value = "saveCustomerClubApply", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo saveCustomerClubApply(CustomerClubApply customerClubApply) {
		try {
			this.customerClubApplyService.saveCustomerClubApply(customerClubApply);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}
	
	/**
	 * 更新
	 * 
	 * @param customerClubApply
	 * @return
	 */
	@RequestMapping(value = "updateCustomerClubApply", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo updateCustomerClubApply(CustomerClubApply customerClubApply) {
		try {
			this.customerClubApplyService.updateCustomerClubApply(customerClubApply);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "removeCustomerClubApply", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo removeCustomerClubApply(long id) {
		try {
			this.customerClubApplyService.removeCustomerClubApply(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 恢复
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "recover", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo recover(long id) {
		try {
			this.customerClubApplyService.recover(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	@RequestMapping(value = "getCustomerClubApply", method = RequestMethod.GET)
	@ResponseBody
	public ResultVo getCustomerClubApply() {
		try {
			return ResultUtil.success((Serializable) this.customerClubApplyService.getCustomerClubApply(this.getCurrentCustomer().getCustomerId()));
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	@RequestMapping(value = "checkCustomerApply", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo checkCustomerApply(CustomerClubApply customerClubApply) {
		try {
            this.customerClubApplyService.checkCustomer(customerClubApply);
			return ResultUtil.success( );
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	@RequestMapping(value = "regiestCustomerCulb", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo regiestCustomerCulb(CustomerClubApply customerClubApply) {
		try {
			customerClubApply.setCustomerId(this.getCurrentCustomer().getId());
			this.customerClubApplyService.regiestCustomerCulb(customerClubApply);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

}